package dp.proxy.handler;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

import dp.proxy.subject.PersonBeanInterface;


public class NonOwnerInvocationHandler implements InvocationHandler {

	PersonBeanInterface personBean;
	
	public NonOwnerInvocationHandler(PersonBeanInterface personBean) {
		this.personBean = personBean;
	}
	
	public Object invoke(Object proxy, Method method, Object[] args)
			throws Throwable {

		try {
			if(method.getName().startsWith("get"))
			{
				return method.invoke(personBean, args);
			}
			else if(method.getName().startsWith("setHotOrNotRating"))
			{
				return method.invoke(personBean, args);
			}
			else if(method.getName().startsWith("set"))
			{
				throw new IllegalAccessException();
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}

}

class A{
	void ma(){}
	int ma(int a){return 0;}
	public static void main(String args[]){
		byte s = (byte)128; //  00000000 10000000
		byte s1 = (byte)256; // 00000001 00000000
		byte s2 = (byte)-256; //11111111 00000000
		System.out.println(s);
		System.out.println(s1);
		System.out.println(Integer.toBinaryString(256));
		System.out.println(Integer.toBinaryString(-256));
		System.out.println(Integer.toBinaryString(-128));
	}
}
